package demo;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-05-19
 * Time: 22:38
 */
class BatteryCharger {
    private int[] rates;
    public BatteryCharger(int[] rates) {
        this.rates = rates;
    }
    public int getChargeCost(int startHour, int chargeTime) {
        int totalCost = 0;
        for (int i = startHour; i < startHour + chargeTime; i++) {
            totalCost += rates[i % 24];
        }
        return totalCost;
    }
    public int getChargeStartTime(int chargeTime) {
        int minCost = Integer.MAX_VALUE;
        int startTime = 0;
        for (int i = 0; i < 24; i++) {
            int cost = getChargeCost(i, chargeTime);
            if (cost < minCost) {
                minCost = cost;
                startTime = i;
            }
        }
        return startTime;
    }
} //在main函数中调用BatteryCharger类的方法
public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] rates = new int[24];
        for (int i = 0; i < 24; i++) {
            rates[i] = scanner.nextInt();
        }
        BatteryCharger charger = new BatteryCharger(rates);
        int startHour = scanner.nextInt();
        int chargeTime = scanner.nextInt();
        int cost = charger.getChargeCost(startHour, chargeTime);
        System.out.println("Total cost: $" + cost);
        int shortestStartTime = charger.getChargeStartTime(chargeTime);
        System.out.println("Shortest start time: " + shortestStartTime);
    }

}
